<template>
  <div class="all">
    <div class="charge">
      <div class="title border_bottom">充值管理</div>
      <div style="display:flex;margin-top:15px">
        <div class="v_center m-right">充值账户</div>
        <van-field disabled label-width="70px" class="form_item" label-class="c_flex f-26 w-200"
          v-model="fee.account" />
      </div>
      <div style="display:flex;margin-top:15px">
        <div class="v_center m-right">充值金额</div>
        <van-field :rules="[{ required: true, message: '请输入正确内容' }]" type="digit" class="form_item" label-width="70px"
          label-class="c_flex f-26 w-200" v-model="fee.amount" />
      </div>
      <van-tabs class="money_tab" @click="change_fee" type="card">
        <van-tab title="10000" :name="10000"></van-tab>
        <van-tab title="20000" :name="20000"></van-tab>
        <van-tab title="30000" :name="30000"></van-tab>
      </van-tabs>
      <div @click="onSubmit" class="sumbit">
        <div class="submit_button c_flex">充值</div>
      </div>
    </div>

    <div class="fee">
      <div class="fee_title w-600">
        加盟费管理
      </div>
      <div class="fee_down c_flex">

        <van-grid :border="false" :gutter="1" class="fee_table">
          <van-grid-item>
            <div class="grid_item" style="border-top-left-radius: 18px">
              品牌保证金(元)
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item">
              加盟费(元)
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item">
              品牌管理费(元)
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item" style="border-top-right-radius: 18px">
              合计(元)
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item" style="border-bottom-left-radius: 18px">
              10000
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item">
              10000
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item">
              10000
            </div>
          </van-grid-item>
          <van-grid-item>
            <div class="grid_item" style="border-bottom-right-radius: 18px">
              10000
            </div>
          </van-grid-item>

        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
  import {
    ShoperService
  } from '@/api'
  export default {
    name: 'financial',
    data() {
      return {
        fee: {
          account: '',
          amount: 10000,
        }
      }
    },
    watch: {
      'this.$route.query.shoper_id': {
        handler(val) {
          console.log(val)
          this.fee.account = this.$route.query.shoper_name
        },
        immediate: true,
        deep: true
      }
    },
    methods: {
      onSubmit() {
        if (!this.fee.account) {
          this.$toast("您的供应商不能为空！")
        }
        if (!this.fee.amount || this.fee.amount < 0) {
          this.$toast("您的金额不能为空！")
        }
        ShoperService.addMoney({
          amount: this.fee.amount,
          msg: '加盟商充值'
        }, this.$route.query.shoper_id).then(res => {
          if (res.code == 10000) {
            this.$toast(`充值${this.fee.amount}元成功!`)
            this.$router.push({
              path: "/detail",
              query: {
                shoper_id: this.$route.query.shoper_id,
              }
            })
          }
        })

      },
      getShoper() {
        ShoperService.getOne({
          relation: 'cars,cooperations,cooperations.attachments'
        }, this.$route.query.shoper_id).then(res => {
          this.shoper = this.handleData(res.data);
          this.cars = res.data.cars;
        })
      },
      change_fee(value) {
        console.log(value)
        this.fee.amount = value;
      }
    },
  }
</script>

<style lang="less" scoped>
  .all {
    padding: 24px;
    background-color: #F3F5F7;
    min-height: 92.3vh;

    .charge {
      padding: 26px 32px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background-color: #ffffff;
      width: 702px;
      height: 511px;
      border-radius: 16px;

      .title {
        align-self: flex-start;
        justify-content: flex-start;
        flex: 1;
        display: flex;
        font-size: 28px;
        font-weight: 600;
        width: 100%;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      }

      .form_item {
        height: 63px;
        width: 362px;
        font-family: SourceHanSansCN-Light;
        border: 2px solid rgba(243, 245, 247, 1);
        border-radius: 10px;
      }

      .money_tab {
        margin-top: 20px;

      }

      /deep/.van-tab.van-tab--active {
        background-color: rgba(243, 149, 27, 1);
        color: #ffffff;
      }

      /deep/.van-tabs__wrap {
        height: auto;
        background-color: rgba(243, 245, 247, 1);
        border-radius: 16px;
      }

      /deep/.van-tabs__nav--card {
        height: auto;
        border: none;
        background-color: rgba(243, 245, 247, 1);
      }

      /deep/.van-tab {
        width: 80px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: rgba(102, 102, 102, 1);
        margin: 8px;
        background-color: #fff;
        border-radius: 8px;
        border: none;
      }

      /deep/.van-tab__text {
        font-size: 22px;
      }

      .sumbit {
        height: 130px;
        padding-top: 39px;
        padding-bottom: 40px;

        .submit_button {
          height: 60px;
          width: 364px;
          background-color: rgba(236, 104, 21, 1);
          color: #ffffff;
          border-radius: 8px;
          font-size: 24px;
        }
      }
    }

    .fee {
      margin-top: 40px;
      width: 702px;
      height: 443px;
      background-color: rgba(255, 255, 255, 1);
      border-radius: 16px;
      display: flex;
      flex-direction: column;

      .fee_title {
        padding: 26px 32px;
        color: rgba(51, 51, 51, 1);
        font-size: 28px;
        border: 1px solid rgba(242, 242, 242, 1);
        height: 80px;
      }

      .fee_down {
        flex: 1;

        .fee_table {
          width: 660px;
          height: 278px;
          border-radius: 25px;

          /deep/.van-grid-item__content {
            padding: 0;
          }

          .grid_item {
            width: 100%;
            height: 100%;
            background-color: rgba(242, 242, 242, 1);
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 20px;
          }
        }
      }
    }
  }
</style>